{{include file ="admin/header.tpl"}} {{include file
="admin/navibar.tpl"}} {{include file ="admin/sidebar.tpl"}}

<link rel="stylesheet" type="text/css"
	href="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript"
	src="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="{{$smarty.const.WEBSITE_URL}}public/assets/lib/ajaxupload.js"></script>
<style>
#addwin {
	margin: -500px 0 0 -280px;
	/* PLAY THE WITH THE VALUES TO SEE GET THE DESIRED EFFECT */
}
</style>
<script type="text/javascript">


//文件上传组件处理
jQuery(function () {

});

	 function modelshow(){ 
		 $('#addwin').modal('show');
	 }
	 function modelhide(){
		 $('#addwin').modal('hide');
	 }
	 
	 
	function newEmail(){
		$("#form").form('clear');
		modelshow();
	}
	
	function editEmail(){
		var select = getSelectEmail();
		if(select == null || select.length == 0 ){
			$.messager.alert('错误','请选择要修改的记录!');
			return;
		}
	
		$("#form").form('clear');
		modelshow();
		$("#form").form('load',select[0]);
	
	}
	function removeEmail(){
		$.messager.confirm('删除确定','确定要删除当前选择的记录!',function(r){
		    if (r){
		    	var select = getSelectEmail();
				if(select == null || select.length == 0 ){
					$.messager.alert('错误','请选择要删除的记录!');
					return;
				}
				$.ajax({  
		            type: "POST",  
		            dataType: "json",  
		            url: '{{$smarty.const.WEBSITE_URL}}admin/emails/delete',
		            data: { id: select[0].id },  
		            success: function (data) {  
		             	$('#grid').datagrid('reload'); 
		            },  
		            error: function () {  
		            }  
		        });  
		    }
		});
		
	}


	function submitStatusChange(){
		  if(!$('#form').form('validate')){
		        return;
		     }
	    $.post(
				'{{$smarty.const.WEBSITE_URL}}admin/emails/save',
				$('#form').serialize(),
				function(data){ 
					modelhide();
			    	$('#grid').datagrid('reload'); 
				},
				"json"
	    );
	}
	  
	function win_close(){
		modelhide();
	}


	function getSelectEmail(){
		var select  = $("#grid").datagrid('getSelections');
		if(select == null || select.length == 0 ){
			return null;
		}
		return select;
	}

		 
</script>

<div class="content">
	<div class="header">
		<div class="stats">
			<p class="stat">
				<!--span class="number"></span-->
			</p>
		</div>

		<h1 class="page-title">email订阅管理</h1>
	</div>

	<!-- <ul class="breadcrumb">
            <li><a href="{{$smarty.const.WEBSITE_URL}}admin/user">管理列表</a> <span class="divider">/</span></li>  
			 <a title= "移除快捷菜单" ><li class="active"><i class="icon-minus" method="del" url="#"></i></li></a>
	         <a title= "加入快捷菜单" ><li class="active"><i class="icon-plus" method="add" url="#"></i></li></a>
        </ul> -->
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="bb-alert alert alert-info" style="display: none;">
				<span>操作成功</span>
			</div>
			<!--- START 以上内容不需更改，保证该TPL页内的标签匹配即可 --->


			<table id="grid"
				data-options="url:'admin/emails/getpage',fitColumns:true,singleSelect:true"
				class="easyui-datagrid" style="width: auto; height: 350px"
				toolbar="#toolbar" iconCls="icons-save" pagination="true"
				rownumbers="true">
				<thead>
					<tr>
						<!-- <th data-options="field:'passwd',hidden:true"></th>
						<th data-options="field:'role_id',hidden:true"></th> -->
						<th data-options="field:'id',width:100,checkbox:true"></th>
						<th data-options="field:'email',width:100">邮箱</th>
						<th data-options="field:'email_origin',width:100">站点</th>
							<th data-options="field:'create_date',width:100">创建时间</th>
						<th data-options="field:'user_name',width:100">用户名</th>
						<th data-options="field:'post_code',width:100">邮编</th>
						<th data-options="field:'country',width:100">国家</th>
					
					</tr>
				</thead>
			</table>

			<div id="toolbar">
				<a  class="easyui-linkbutton" href="javascript:void(0)"  iconCls="icons-add"
					plain="true" onclick="newEmail()">添加email</a> <a  href="javascript:void(0)" 
					class="easyui-linkbutton" iconCls="icons-edit" plain="true"
					onclick="editEmail()">修改emial</a> <a  href="javascript:void(0)" 
					class="easyui-linkbutton" iconCls="icons-remove" plain="true"
					onclick="removeEmail()">删除email</a>
			</div>



			<div id="addwin" class="modal hide fade">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h5>emial信息管理</h5>
				</div>
				<div class="modal-body">
					<form id="form" method="post" class="form-horizontal">
						<div class="control-group" hidden="true">
							<input type="text" name="id" hidden="true">
						</div>
						<div class="control-group">
							<label class="control-label" for="Text input">邮箱:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="email" name="email"
									 placeholder="Email">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="inputPassword">站点:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="email_origin" name="email_origin"
									placeholder="请输入站点">
							</div>
						</div>

						<div class="control-group">
							<label class="control-label" for="Text input">用户名:</label>
							<div class="controls">
								<input type="text" id="user_name" name="user_name"
									placeholder="用户名">
							</div>
						</div>


						<div class="control-group">
							<label class="control-label" for="inputEmail">邮编:</label>
							<div class="controls">
								<input type="text" id="post_code" name="post_code" placeholder="请输入邮编">
							</div>
						</div>

						<div class="control-group">
							<label class="control-label" for="Text input">国家:</label>
							<div class="controls">
								<input type="text" id="country" name="country" placeholder="国家">
							</div>
						</div>

					</form>
				</div>
				<div class="modal-footer" id="div_view">
					<button type="button" style="width: 100px;" class="btn btn-primary"
						onclick="submitStatusChange()">提交</button>
					<button type="button" onclick="win_close()" style="width: 100px;"
						class="btn">取消</button>

				</div>
			</div>

			<!--- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 --->
			{{include file="admin/footer.tpl" }}